package leetcode;

public class PalindRomicInteger {

	public boolean isPalindRomicInteger(int x){
		if(x<0)return false;
		if(x>=0&&x<10)return true;
		int base=1;
		int left=0,right=0;
		while(x/base>=10){
			base*=10;
		}
		while(x!=0){
			left=x/base;
			right=x%10;
			if(left!=right){
				return false;
			}
			x-=base*left;
			base/=100;
			x/=10;
		}
		return true;
	}
	
	public static void main(String[] args) {
		PalindRomicInteger p=new PalindRomicInteger();
		//System.out.println(p.isPalindRomicInteger(0));
		System.out.println(p.isPalindRomicInteger(100001));
		System.out.println(p.isPalindRomicInteger(1000021));
		System.out.println(p.isPalindRomicInteger(123));
		System.out.println(p.isPalindRomicInteger(121));
		System.out.println(p.isPalindRomicInteger(1221));
	}
}
